function db(sql,callback){
     const mysql = require('mysql')
     const conn = mysql.createConnection({
         host:'localhost',
         user:'root',
         password:'',
         database:'dashijian' 
     });
     conn.connect();
     conn.query(sql,callback);
     conn.end();
}

// 封装之后，函数在其它文件中使用，所以要导出
module.exports = db;


// 调用
// db('select * from student',(err,result) => {
//     if(err) throw err;
//     console.log(result);
// })